{extend name="../../base/view/layout" /}
{block name="my_body"}
<div class="maincontent">
    <div class="maincontentinner">

        <table id="dyntable" class="table table-bordered responsive">
            <thead>
            <tr>
                <th class="center"><input type="checkbox" class="checkall" /></th>
                <th class="center">ID</th>
                <th class="center">商品信息</th>
                <th class="center">店铺</th>
                <th class="center">配送信息</th>
                <th class="center">主要信息</th>
                <th class="center">促销信息</th>
                <th class="center">推荐信息</th>
                <th class="center">状态信息</th>
                <th class="center">时间信息</th>
                <th class="center">操作</th>
            </tr>
            </thead>
            <tbody>
            <?php foreach($data as $v):?>
            <tr >
                <td class="aligncenter"><span class="center">
                            <input type="checkbox" />
                          </span></td>
                <td class="center "><?php echo $v['id'];?></td>
                <td class="center">
                    <?php echo $v['goods_name'];?><br />
                    <?php if(!empty($v['sm_logo'])):?>
                    <?php showImage($v['sm_logo']);?>
                    <?php endif;?>
                </td>
                <td class="center"><?php echo $v['shop_name'];?></td>
                <td class="center">
                    货号:<?php echo $v['goods_sn'];?><br />
                    配送属性:<?php  $v['ps_attr'] == 1?$p = '发货':$p='不发货';?><?php echo $p;?><br />
                    配送方式:<?php  $v['psfs_id'] == 0?$p = '包邮':$p='';?><?php echo $p;?><br />
                </td>

                <td class="center">
                    品牌:<?php echo $v['brand_name'];?><br />
                    分类:<?php echo $v['cat_name'];?><br />
                    类型:<?php echo $v['type_name'];?><br />
                </td>

                <td class="center">
                    <?php if($v['promote_start_date'] < time() && $v['promote_end_date'] >= time()):?>
                    开始时间:<?php echo date('Y-m-d H:i:s',$v['promote_start_date']);?><br />
                    结束时间:<?php echo date('Y-m-d H:i:s',$v['promote_end_date']);?><br />
                    <?php else:?>
                        无促销
                    <?php endif;?>
                </td>

                <td class="center">
                    是否新品:<?php  $v['is_new'] == 1?$p = '是':$p='否';echo $p; ?><br />
                    是否热卖:<?php  $v['is_hot'] == 1?$p = '是':$p='否';echo $p; ?><br />
                    是否精品:<?php  $v['is_best'] == 1?$p = '是':$p='否';echo $p; ?><br />
                    是否推荐:<?php  $v['is_floor'] == 1?$p = '是':$p='否';echo $p; ?><br />
                    是否折扣:<?php  $v['is_discount'] == 1?$p = '是':$p='否';echo $p; ?><br />
                </td>

                <td class="center">
                    是否审核:<?php  $v['is_sh'] == 1?$p = '是':$p='否';echo $p; ?><br />
                    是否上架:<?php  $v['is_on_sale'] == 1?$p = '是':$p='否';echo $p; ?><br />
                </td>

                <td class="center">
                    添加时间:<?php echo date('Y-m-d H:i:s',$v['created_at']);?><br />
                    修改时间:<?php echo date('Y-m-d H:i:s',$v['updated_at']);?><br />
                </td>
                <td class="center">
                    <?php if($v['is_sh'] == 0):?>
                    <a thisid="<?php echo $v['id'];?>" href="javascript:;" onclick="review(this)">审核</a><br />
                    <?php endif;?>
                    <a href="<?php echo url('/shop/Goodsattr/lst',['id'=>$v['id']]);?>">商品属性列表</a><br />
                    <a href="<?php echo url('edit',['id'=>$v['id']]);?>">修改</a><br />
                    <a thisid="<?php echo $v['id'];?>" href="javascript:;" onclick="del(this)">删除</a>
                </td>
            </tr>
            <?php endforeach;?>

            </tbody>
        </table>

        <br /><br />

        <?php echo $page;?>

    </div><!--maincontentinner-->
</div><!--maincontent-->
{/block}

{block name="my_js"}
<script>
    function del(t)
    {
        var id = jQuery(t).attr('thisid');
        var url = "<?php echo url('del');?>";
                jQuery.ajax({
                    type: 'POST',
                    url: url,
                    data:"id="+id,
                    dataType: 'JSON',
                    success: function(res){
                        if(res.code == 0)
                        {
                            window. location.reload();
                        }
                        else
                        {
                            var html = '<div class="widgetbox box-danger"><h4 class="widgettitle">错误提示 <a class="close">×</a> <a class="minimize">–</a></h4><div class="widgetcontent">'+res.msg+'</div></div>';
                            var h = jQuery(html);
                            jQuery(".maincontentinner").prepend(h);
                            window.setTimeout(function(){
                                h.remove();
                            },1000);
                        }
                    }
                })
    }

    function review(t)
    {
        var id = jQuery(t).attr('thisid');
        var url = "<?php echo url('review');?>";
        jQuery.ajax({
            type: 'POST',
            url: url,
            data:"id="+id,
            dataType: 'JSON',
            success: function(res){
                if(res.code == 0)
                {
                    window. location.reload();
                }
                else
                {
                    var html = '<div class="widgetbox box-danger"><h4 class="widgettitle">错误提示 <a class="close">×</a> <a class="minimize">–</a></h4><div class="widgetcontent">'+res.msg+'</div></div>';
                    var h = jQuery(html);
                    jQuery(".maincontentinner").prepend(h);
                    window.setTimeout(function(){
                        h.remove();
                    },1000);
                }
            }
        })
    }
</script>
{/block}
